{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\n\n/**\n * Removed props:\n *  - childrenProps\n */\nimport { alignElement, alignPoint } from 'dom-align';\nimport isEqual from \"rc-util/es/isEqual\";\nimport addEventListener from \"rc-util/es/Dom/addEventListener\";\nimport isVisible from \"rc-util/es/Dom/isVisible\";\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport { composeRef } from \"rc-util/es/ref\";\nimport React from 'react';\nimport useBuffer from \"./hooks/useBuffer\";\nimport { isSamePoint, monitorResize, restoreFocus } from \"./util\";\nfunction getElement(func) {\n  if (typeof func !== 'function') return null;\n  return func();\n}\nfunction getPoint(point) {\n  if (_typeof(point) !== 'object' || !point) return null;\n  return point;\n}\nvar Align = function Align(_ref, ref) {\n  var children = _ref.children,\n    disabled = _ref.disabled,\n    target = _ref.target,\n    align = _ref.align,\n    onAlign = _ref.onAlign,\n    monitorWindowResize = _ref.monitorWindowResize,\n    _ref$monitorBufferTim = _ref.monitorBufferTime,\n    monitorBufferTime = _ref$monitorBufferTim === void 0 ? 0 : _ref$monitorBufferTim;\n  var cacheRef = React.useRef({});\n  /** Popup node ref */\n\n  var nodeRef = React.useRef();\n  var childNode = React.Children.only(children); // ===================== Align ======================\n  // We save the props here to avoid closure makes props ood\n\n  var forceAlignPropsRef = React.useRef({});\n  forceAlignPropsRef.current.disabled = disabled;\n  forceAlignPropsRef.current.target = target;\n  forceAlignPropsRef.current.align = align;\n  forceAlignPropsRef.current.onAlign = onAlign;\n  var _useBuffer = useBuffer(function () {\n      var _forceAlignPropsRef$c = forceAlignPropsRef.current,\n        latestDisabled = _forceAlignPropsRef$c.disabled,\n        latestTarget = _forceAlignPropsRef$c.target,\n        latestAlign = _forceAlignPropsRef$c.align,\n        latestOnAlign = _forceAlignPropsRef$c.onAlign;\n      var source = nodeRef.current;\n      if (!latestDisabled && latestTarget && source) {\n        var _result;\n        var _element = getElement(latestTarget);\n        var _point = getPoint(latestTarget);\n        cacheRef.current.element = _element;\n        cacheRef.current.point = _point;\n        cacheRef.current.align = latestAlign; // IE lose focus after element realign\n        // We should record activeElement and restore later\n\n        var _document = document,\n          activeElement = _document.activeElement; // We only align when element is visible\n\n        if (_element && isVisible(_element)) {\n          _result = alignElement(source, _element, latestAlign);\n        } else if (_point) {\n          _result = alignPoint(source, _point, latestAlign);\n        }\n        restoreFocus(activeElement, source);\n        if (latestOnAlign && _result) {\n          latestOnAlign(source, _result);\n        }\n        return true;\n      }\n      return false;\n    }, monitorBufferTime),\n    _useBuffer2 = _slicedToArray(_useBuffer, 2),\n    _forceAlign = _useBuffer2[0],\n    cancelForceAlign = _useBuffer2[1]; // ===================== Effect =====================\n  // Handle props change\n\n  var _React$useState = React.useState(),\n    _React$useState2 = _slicedToArray(_React$useState, 2),\n    element = _React$useState2[0],\n    setElement = _React$useState2[1];\n  var _React$useState3 = React.useState(),\n    _React$useState4 = _slicedToArray(_React$useState3, 2),\n    point = _React$useState4[0],\n    setPoint = _React$useState4[1];\n  useLayoutEffect(function () {\n    setElement(getElement(target));\n    setPoint(getPoint(target));\n  });\n  React.useEffect(function () {\n    if (cacheRef.current.element !== element || !isSamePoint(cacheRef.current.point, point) || !isEqual(cacheRef.current.align, align)) {\n      _forceAlign();\n    }\n  }); // Watch popup element resize\n\n  React.useEffect(function () {\n    var cancelFn = monitorResize(nodeRef.current, _forceAlign);\n    return cancelFn;\n  }, [nodeRef.current]); // Watch target element resize\n\n  React.useEffect(function () {\n    var cancelFn = monitorResize(element, _forceAlign);\n    return cancelFn;\n  }, [element]); // Listen for disabled change\n\n  React.useEffect(function () {\n    if (!disabled) {\n      _forceAlign();\n    } else {\n      cancelForceAlign();\n    }\n  }, [disabled]); // Listen for window resize\n\n  React.useEffect(function () {\n    if (monitorWindowResize) {\n      var cancelFn = addEventListener(window, 'resize', _forceAlign);\n      return cancelFn.remove;\n    }\n  }, [monitorWindowResize]); // Clear all if unmount\n\n  React.useEffect(function () {\n    return function () {\n      cancelForceAlign();\n    };\n  }, []); // ====================== Ref =======================\n\n  React.useImperativeHandle(ref, function () {\n    return {\n      forceAlign: function forceAlign() {\n        return _forceAlign(true);\n      }\n    };\n  }); // ===================== Render =====================\n\n  if ( /*#__PURE__*/React.isValidElement(childNode)) {\n    childNode = /*#__PURE__*/React.cloneElement(childNode, {\n      ref: composeRef(childNode.ref, nodeRef)\n    });\n  }\n  return childNode;\n};\nvar RcAlign = /*#__PURE__*/React.forwardRef(Align);\nRcAlign.displayName = 'Align';\nexport default RcAlign;","map":{"version":3,"names":["_slicedToArray","_typeof","alignElement","alignPoint","isEqual","addEventListener","isVisible","useLayoutEffect","composeRef","React","useBuffer","isSamePoint","monitorResize","restoreFocus","getElement","func","getPoint","point","Align","_ref","ref","children","disabled","target","align","onAlign","monitorWindowResize","_ref$monitorBufferTim","monitorBufferTime","cacheRef","useRef","nodeRef","childNode","Children","only","forceAlignPropsRef","current","_useBuffer","_forceAlignPropsRef$c","latestDisabled","latestTarget","latestAlign","latestOnAlign","source","_result","_element","_point","element","_document","document","activeElement","_useBuffer2","_forceAlign","cancelForceAlign","_React$useState","useState","_React$useState2","setElement","_React$useState3","_React$useState4","setPoint","useEffect","cancelFn","window","remove","useImperativeHandle","forceAlign","isValidElement","cloneElement","RcAlign","forwardRef","displayName"],"sources":["/data/messenger.client/node_modules/rc-align/es/Align.js"],"sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\n\n/**\n * Removed props:\n *  - childrenProps\n */\nimport { alignElement, alignPoint } from 'dom-align';\nimport isEqual from \"rc-util/es/isEqual\";\nimport addEventListener from \"rc-util/es/Dom/addEventListener\";\nimport isVisible from \"rc-util/es/Dom/isVisible\";\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport { composeRef } from \"rc-util/es/ref\";\nimport React from 'react';\nimport useBuffer from \"./hooks/useBuffer\";\nimport { isSamePoint, monitorResize, restoreFocus } from \"./util\";\n\nfunction getElement(func) {\n  if (typeof func !== 'function') return null;\n  return func();\n}\n\nfunction getPoint(point) {\n  if (_typeof(point) !== 'object' || !point) return null;\n  return point;\n}\n\nvar Align = function Align(_ref, ref) {\n  var children = _ref.children,\n      disabled = _ref.disabled,\n      target = _ref.target,\n      align = _ref.align,\n      onAlign = _ref.onAlign,\n      monitorWindowResize = _ref.monitorWindowResize,\n      _ref$monitorBufferTim = _ref.monitorBufferTime,\n      monitorBufferTime = _ref$monitorBufferTim === void 0 ? 0 : _ref$monitorBufferTim;\n  var cacheRef = React.useRef({});\n  /** Popup node ref */\n\n  var nodeRef = React.useRef();\n  var childNode = React.Children.only(children); // ===================== Align ======================\n  // We save the props here to avoid closure makes props ood\n\n  var forceAlignPropsRef = React.useRef({});\n  forceAlignPropsRef.current.disabled = disabled;\n  forceAlignPropsRef.current.target = target;\n  forceAlignPropsRef.current.align = align;\n  forceAlignPropsRef.current.onAlign = onAlign;\n\n  var _useBuffer = useBuffer(function () {\n    var _forceAlignPropsRef$c = forceAlignPropsRef.current,\n        latestDisabled = _forceAlignPropsRef$c.disabled,\n        latestTarget = _forceAlignPropsRef$c.target,\n        latestAlign = _forceAlignPropsRef$c.align,\n        latestOnAlign = _forceAlignPropsRef$c.onAlign;\n    var source = nodeRef.current;\n\n    if (!latestDisabled && latestTarget && source) {\n      var _result;\n\n      var _element = getElement(latestTarget);\n\n      var _point = getPoint(latestTarget);\n\n      cacheRef.current.element = _element;\n      cacheRef.current.point = _point;\n      cacheRef.current.align = latestAlign; // IE lose focus after element realign\n      // We should record activeElement and restore later\n\n      var _document = document,\n          activeElement = _document.activeElement; // We only align when element is visible\n\n      if (_element && isVisible(_element)) {\n        _result = alignElement(source, _element, latestAlign);\n      } else if (_point) {\n        _result = alignPoint(source, _point, latestAlign);\n      }\n\n      restoreFocus(activeElement, source);\n\n      if (latestOnAlign && _result) {\n        latestOnAlign(source, _result);\n      }\n\n      return true;\n    }\n\n    return false;\n  }, monitorBufferTime),\n      _useBuffer2 = _slicedToArray(_useBuffer, 2),\n      _forceAlign = _useBuffer2[0],\n      cancelForceAlign = _useBuffer2[1]; // ===================== Effect =====================\n  // Handle props change\n\n\n  var _React$useState = React.useState(),\n      _React$useState2 = _slicedToArray(_React$useState, 2),\n      element = _React$useState2[0],\n      setElement = _React$useState2[1];\n\n  var _React$useState3 = React.useState(),\n      _React$useState4 = _slicedToArray(_React$useState3, 2),\n      point = _React$useState4[0],\n      setPoint = _React$useState4[1];\n\n  useLayoutEffect(function () {\n    setElement(getElement(target));\n    setPoint(getPoint(target));\n  });\n  React.useEffect(function () {\n    if (cacheRef.current.element !== element || !isSamePoint(cacheRef.current.point, point) || !isEqual(cacheRef.current.align, align)) {\n      _forceAlign();\n    }\n  }); // Watch popup element resize\n\n  React.useEffect(function () {\n    var cancelFn = monitorResize(nodeRef.current, _forceAlign);\n    return cancelFn;\n  }, [nodeRef.current]); // Watch target element resize\n\n  React.useEffect(function () {\n    var cancelFn = monitorResize(element, _forceAlign);\n    return cancelFn;\n  }, [element]); // Listen for disabled change\n\n  React.useEffect(function () {\n    if (!disabled) {\n      _forceAlign();\n    } else {\n      cancelForceAlign();\n    }\n  }, [disabled]); // Listen for window resize\n\n  React.useEffect(function () {\n    if (monitorWindowResize) {\n      var cancelFn = addEventListener(window, 'resize', _forceAlign);\n      return cancelFn.remove;\n    }\n  }, [monitorWindowResize]); // Clear all if unmount\n\n  React.useEffect(function () {\n    return function () {\n      cancelForceAlign();\n    };\n  }, []); // ====================== Ref =======================\n\n  React.useImperativeHandle(ref, function () {\n    return {\n      forceAlign: function forceAlign() {\n        return _forceAlign(true);\n      }\n    };\n  }); // ===================== Render =====================\n\n  if ( /*#__PURE__*/React.isValidElement(childNode)) {\n    childNode = /*#__PURE__*/React.cloneElement(childNode, {\n      ref: composeRef(childNode.ref, nodeRef)\n    });\n  }\n\n  return childNode;\n};\n\nvar RcAlign = /*#__PURE__*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